package com.tang.service.impl;

import com.tang.dao.FoodDao;
import com.tang.entity.Food;
import com.tang.mapper.FoodMapper;
import com.tang.pojo.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import com.tang.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务接口实现
 *
 * @author kancy
 * @since 2024-07-21 14:12:37
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class FoodServiceImpl implements FoodService {
    @Autowired
    private final FoodDao foodDao;


    @Autowired
    private FoodMapper foodMapper;

    @Override
    public List<Food> list() {

        //先查询redis

        //查询到返回结果

        //未查询到查询数据库 存入redis

        //再次查询redis

        //存入redis



        List<Food> list = foodDao.list();
        return list;
    }

    @Override
    public Result<List<Food>> getByFoodName(String foodName) {

        List<Food> list=foodMapper.getByFoodName(foodName);
        return Result.success(list);
    }

    @Override
    public Result addFood(Long foodId, Float number, Integer type) {
        return null;
    }


}